import { PathType } from "./clipper";
import { Vertex, VertexFlag } from "./vertex";
export class LocalMin {
  type: PathType;
  v: Vertex;
  properties: any;
  constructor(v: Vertex, type: PathType, properties: any = undefined) {
    v.flag |= VertexFlag.LOCAL_MIN;
    this.v = v;
    this.type = type;
    this.properties = properties;
  }

  static compare(lm1: LocalMin, lm2: LocalMin) {
    let ret: number;
    let x1 = lm1.v.x;
    let y1 = lm1.v.y;
    let x2 = lm2.v.x;
    let y2 = lm2.v.y;

    if (y1 !== y2) {
      ret = y1 > y2 ? -1 : 1;
    } else if (x1 !== x2) {
      ret = x1 < x2 ? -1 : 1;
    } else {
      ret = 0;
    }
    return ret;
  }
}
